import java.util.ArrayList;

public class ErrorLogin {
    public String name = "admin";
    public String password = "123456";

    public void login(String name,String password){
        if (!this.password.equals(password)){
            System.out.println("密码错误!");
            throw new PasswordException("你密码错了!");
        }
        if (!this.password.equals(name)){
            System.out.println("用户名错误!");
            throw new UsernameException("你用户名错了！");
        }

    }

    public static void main(String[] args) {
        ErrorLogin errorLogin = new ErrorLogin();
        try{
            errorLogin.login("admin","12345");
        }catch (UsernameException e){
            e.printStackTrace();
            System.out.println("用户名异常");
        }catch (PasswordException passwordException){
            passwordException.printStackTrace();
            System.out.println("密码异常");
        }finally {

        }
    }
}
